home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_qt3.idb / usr / freeware / Qt / examples / iconview / main.cpp.z / main.cpp
Encoding:
C/C++ Source or Header  |  2002-04-08  |  2.0 KB  |  77 lines

  1. /****************************************************************************
  2. ** $Id:  qt/main.cpp   3.0.3   edited Nov 13 08:47 $
  3. **
  4. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  5. **
  6. ** This file is part of an example program for Qt.  This example
  7. ** program may be used, distributed and modified without limitation.
  8. **
  9. *****************************************************************************/
  10.  
  11. #include <qiconview.h>
  12. #include <qapplication.h>
  13. #include <qdragobject.h>
  14. #include <qpixmap.h>
  15. #include <qiconset.h>
  16.  
  17. #include <qmime.h>
  18. #include <stdio.h>
  19.  
  20. class ListenDND : public QObject
  21. {
  22.     Q_OBJECT
  23.  
  24. public:
  25.     ListenDND( QWidget *w )
  26.         : view( w )
  27.     {}
  28.  
  29. public slots:
  30.     void dropped( QDropEvent *mime ) {
  31.         qDebug( "Dropped Mimesource %p into the view %p", mime, view );
  32.         qDebug( "  Formats:" );
  33.         int i = 0;
  34.         const char *str = mime->format( i );
  35.         qDebug( "    %s", str );
  36.         while ( str ) {
  37.             qDebug( "    %s", str );
  38.             str = mime->format( ++i );
  39.         }
  40.     };
  41.     void moved() {
  42.         qDebug( "All selected items were moved to another widget" );
  43.     }
  44.  
  45. protected:
  46.     QWidget *view;
  47.  
  48. };
  49.  
  50. int main( int argc, char **argv )
  51. {
  52.     QApplication a( argc, argv );
  53.  
  54.     QIconView qiconview;
  55.     qiconview.setSelectionMode( QIconView::Extended );
  56.  
  57.     for ( unsigned int i = 0; i < 3000; i++ ) {
  58.     QIconViewItem *item = new QIconViewItem( &qiconview, QString( "Item %1" ).arg( i + 1 ) );
  59.     item->setRenameEnabled( TRUE );
  60.     }
  61.  
  62.     qiconview.setCaption( "Qt Example - Iconview" );
  63.  
  64.     ListenDND listen_dnd( &qiconview );
  65.     QObject::connect( &qiconview, SIGNAL( dropped( QDropEvent *, const QValueList<QIconDragItem> & ) ),
  66.               &listen_dnd, SLOT( dropped( QDropEvent * ) ) );
  67.     QObject::connect( &qiconview, SIGNAL( moved() ), &listen_dnd, SLOT( moved() ) );
  68.  
  69.     a.setMainWidget( &qiconview );
  70.     qiconview.show();
  71.     qiconview.resize( qiconview.sizeHint() );
  72.  
  73.     return a.exec();
  74. }
  75.  
  76. #include "main.moc"
  77.